package com.hlhj.funlike_business.moudle;

import android.content.Context;

import com.example.mymvp.mvp.BaseModule;
import com.hlhj.funlike_business.api.Apis;
import com.hlhj.funlike_business.api.BaseObser;
import com.hlhj.funlike_business.bean.CommentListBean;
import com.hlhj.funlike_business.bean.MsgBean;
import com.lzy.okgo.model.Response;

import java.util.List;

public class CommentMoudle implements BaseModule{
    public interface getCommentList{
        void loadCommentList(List<CommentListBean.DataBeanX.DataBean> dataBeans);

        void showResult(String msg);
    }

    public getCommentList listener;

    public void setListener(getCommentList listener) {
        this.listener = listener;
    }

    public void LoadCommentList(Context context,int page){
        Apis.INSTANCE.CommentList(page)
                .subscribe(new BaseObser<Response<CommentListBean>>(context) {
                    @Override
                    public void httpSuccess(Response<CommentListBean> commentListBeanResponse) {
                        if (listener!=null){
                            listener.loadCommentList(commentListBeanResponse.body().getData().getData());
                        }
                    }
                });
    }

    public void LoadDelResult(Context context,int id){
        Apis.INSTANCE.DelComment(id)
                .subscribe(new BaseObser<Response<MsgBean>>(context) {
                    @Override
                    public void httpSuccess(Response<MsgBean> msgBeanResponse) {
                        if (listener!=null){
                            listener.showResult(msgBeanResponse.body().getMsg());
                        }
                    }
                });
    }
    public void LoadReplyResult(Context context,int id,String content){
        Apis.INSTANCE.ReplyComment(id,content)
                .subscribe(new BaseObser<Response<MsgBean>>(context) {
                    @Override
                    public void httpSuccess(Response<MsgBean> msgBeanResponse) {
                        if (listener!=null){
                            listener.showResult(msgBeanResponse.body().getMsg());
                        }
                    }
                });
    }

}
